# 访问者接口
class Visitor:
    def visit_concrete_element_a(self, element_a):
        pass

    def visit_concrete_element_b(self, element_b):
        pass

    # 具体访问者


class ConcreteVisitor(Visitor):
    def visit_concrete_element_a(self, element_a):
        print(f"Visiting ConcreteElementA: {element_a.operation_a()}")

    def visit_concrete_element_b(self, element_b):
        print(f"Visiting ConcreteElementB: {element_b.operation_b()}")

    # 元素接口


class Element:
    def accept(self, visitor):
        pass

    # 具体元素 A


class ConcreteElementA(Element):
    def operation_a(self):
        return "ConcreteElementA"

    def accept(self, visitor):
        visitor.visit_concrete_element_a(self)

    # 具体元素 B


class ConcreteElementB(Element):
    def operation_b(self):
        return "ConcreteElementB"

    def accept(self, visitor):
        visitor.visit_concrete_element_b(self)

    # 使用示例


if __name__ == "__main__":
    visitor = ConcreteVisitor()

    element_a = ConcreteElementA()
    element_a.accept(visitor)  # 输出：Visiting ConcreteElementA: ConcreteElementA

    element_b = ConcreteElementB()
    element_b.accept(visitor)  # 输出：Visiting ConcreteElementB: ConcreteElementB

"""
Visiting ConcreteElementA: ConcreteElementA
Visiting ConcreteElementB: ConcreteElementB
"""